package com.mini.game.bus.userdata.convert;

import com.mini.common.util.JacksonUtil;
import com.mini.game.bus.userdata.vo.TaskVo;
import javax.persistence.AttributeConverter;

/**
 * @author 小鱼儿
 * @date 2020/9/1 15:38
 */
public class TaskVo2JsonConverter implements AttributeConverter<TaskVo, String> {
    @Override
    public String convertToDatabaseColumn(TaskVo attribute) {
        if (attribute == null) {
            return null;
        }
        return JacksonUtil.toJsonString(attribute);
    }

    @Override
    public TaskVo convertToEntityAttribute(String dbData) {
        if (dbData == null) {
            return null;
        }
        return JacksonUtil.stringToBean(dbData, TaskVo.class);
    }
}
